const path = require('path')
const fs = require('fs')


function wide(dir) {
    let arr = [dir]
    let index = 0;
    let current;
 
    while(current = arr[index++]) {
        console.log(current)
        let dirs = fs.readdirSync(current);
        dirs = dirs.map(item=>path.join(current,item))
        arr = [...arr,...dirs]
    }
    // 循环arr删除即可
    console.log(arr)
    while(arr.length) {
        fs.rmdir(arr[arr.length-1],(err,cb)=>{
            console.log('删除成功')
        })
    }
}



wide(path.resolve(__dirname,'a'))
